<template>
	<view class="content">
		<image class="gift-img" :src="info.picture" mode=""></image>
		<view class="gift-disc">
			<view class="gift-title">{{info.title}} </view>
			<view class="gift-subTitle"> {{info.sub_title}} </view>
			<view class="gift-time"> {{info.created_at}} </view>
		</view>
		<read-more :intro="info.intro"></read-more>
		
	</view>
</template>

<script>
	import serve from '../static/request.js';
	import storage from '../static/appkey.js';
	import common from '../static/jump.js';
	import {Base64} from '../static/base64.min.js';
	export default {
		data() {
			return {
				id : 0,
				info: {},
			}
		},
		methods: {
			getInfo() {
				var self = this;
				serve.request({
				    url: '/marketing/gift-bag/view',
				    data: {
				        appkey: uni.getStorageSync('appkey'),
				        'access-token': uni.getStorageSync('access-token'),
				        'local-city':uni.getStorageSync('localCity'),
				        id: self.id
				    }
				}).then(res => {
				    if(res.code != 200) {
				        uni.showToast({
				            title: res.message,
				            icon : 'none',
				            success:function(){ 
				                setTimeout(function () { 
				                    common.jump('return_one')
				                }, 2000) 
				            } 
				        });
				        return;
				    }
				    self.info = res.data;
				    // self.info.intro = Base64.decode(res.data.intro).replace(/\<img/gi, '<img style="max-width:100%;height:auto" ');
				});
			},
			jump(jump_type, jump_link) {
				common.jump(jump_type, jump_link);
			}
		},
		onLoad(option) {
			this.id = option.id || 0;
			if(this.id == 0) {
				uni.showToast({
					title: "错误的访问方式",
					icon: 'none',
					success() {
						setTimeout(function () {
							this.jump('return_one')
						}, 2000) 
					}
				});
			}
			this.getInfo();
		},
		onShow() {
			
		},
		onPullDownRefresh() {
			this.getInfo();
		}
	}
</script>

<style scoped lang="scss">
	.content{
		padding-bottom: 100rpx;
	}
	
	.gift-img{width: 100vw;
    height: 100vw;}
	.gift-disc{    padding: 30rpx;border-bottom: 2rpx solid #e4e4e4;}
	.gift-title{
		overflow: hidden;
		    white-space: nowrap;
		    text-overflow: ellipsis;
		    line-height: 80rpx;
		    color: #333;
		    font-size: 36rpx;
	}
	.gift-subTitle{
		font-size: 32rpx;
		    line-height: 50rpx;
		    color: #333;
		    -webkit-line-clamp: 2;
		    overflow: hidden;
		    word-break: break-all;
		    text-overflow: ellipsis;
		    display: -webkit-box;
		    -webkit-box-orient: vertical;
	}
	.gift-time{color: #aaa;
    font-size: 28rpx;
    margin-top: 20rpx;}

	
	
</style>
